<template>
	<div>
		<el-form ref="form" :model="form" label-width="100px">

			<!-- <el-form-item label="序号" prop="nId">
				<el-input v-model="form.nId"></el-input>
			</el-form-item> -->
			<el-form-item label="客户姓名" prop="customer">
				<el-input v-model="form.customer"></el-input>
			</el-form-item>
			<el-form-item label="护理项目" prop="project">

				<el-select v-model="form.project" placeholder="请选择护理项目" clearable :style="{width: '100%'}">
					<el-option v-for="(item, index) in projectData" :key="index" :label="item.name" :value="item.name"
						:disabled="item.disabled"></el-option>
				</el-select>

			</el-form-item>
			<el-form-item label="护理时间" prop="time">
				<el-date-picker v-model="form.time" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
					:style="{width: '100%'}" placeholder="请输入时间" clearable>
				</el-date-picker>
			</el-form-item>
			<el-form-item label="数量" prop="number">
				<el-input v-model="form.number"></el-input>
			</el-form-item>
			<el-form-item label="护理内容" prop="content">
				<el-input v-model="form.content"></el-input>
			</el-form-item>
			<el-form-item label="护理人员" prop="people">

				<el-select v-model="form.people" placeholder="请选择护理人员" clearable :style="{width: '100%'}">
					<el-option v-for="(item, index) in peopleData" :key="index" :label="item.staffName"
						:value="item.staffName" :disabled="item.disabled"></el-option>
				</el-select>

			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>

	</div>
</template>

<script>
	export default {
		name: 'nurseRecordEdit',
		components: {

		},
		props: [
			'showEdit',
			'nid',
			'editid'
		],
		data() {
			return {
				form: {
					nId: '',
					customer: '',
					project: '',
					time: '',
					number: '',
					content: '',
					people: ''
				},
				projectData: [],
				peopleData: [],
				url: '/nurseRecord/save',
				depts: [],
			}
		},
		created() {
			console.log("this.editid:" + this.editid)
			if (this.editid) {
				this.axios.get('/nurseRecord/toedit', response => {
					this.form.nId = response.obj.nid
					this.form.customer = response.obj.customer
					this.form.project = response.obj.project
					this.form.time = response.obj.time
					this.form.number = response.obj.number
					this.form.content = response.obj.content
					this.form.people = response.obj.people
				}, {
					nId: this.editid
				})
			}
			//查询启用的护理内容名单

			this.axios.get('/nContent/getProjectData', res => {
				this.projectData = res.obj
			})
			this.axios.get('/staffManagement/getPeopleData', re => {
				console.log(re.obj)
				this.peopleData = re.obj
			})

		},
		methods: {
			save() {
				this.$refs['form'].validate((valid) => {
					if (valid) {
						this.axios.post(this.url, response => {
							// 子组件要改变父组件的值
							this.$emit('update:show', false)
							this.$emit('getData')
						}, this.form)
					}
				})
			}

		}
	}
</script>

<style>
</style>
